package com.example.asus.testskip.DGPhone;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Random;

/* renamed from: dg.ca.com.DGPhone.GlowingText */
public class GlowingText {
    private Activity activity;
    /* access modifiers changed from: private */
    public float currentGlowRadius = this.startGlowRadius;
    /* access modifiers changed from: private */

    /* renamed from: dx */
    public float f22dx = 0.0f;
    /* access modifiers changed from: private */

    /* renamed from: dy */
    public float f23dy = 0.0f;
    /* access modifiers changed from: private */
    public int glowColor = -1;
    /* access modifiers changed from: private */
    public int glowSpeed;
    /* access modifiers changed from: private */
    public Handler handler;
    /* access modifiers changed from: private */
    public boolean isDirectionUp = true;
    private Context mContext;
    /* access modifiers changed from: private */
    public float maxGlowRadius;
    /* access modifiers changed from: private */
    public float minGlowRadius;

    /* renamed from: r */
    private Runnable f24r;
    /* access modifiers changed from: private */
    public float startGlowRadius;
    /* access modifiers changed from: private */
    public View view;

    public GlowingText(Activity mActivity, Context context, View v, float minRadius, float maxRadius, float startRadius, int color, int speed) {
        this.activity = mActivity;
        this.mContext = context;
        this.view = v;
        this.minGlowRadius = minRadius;
        this.maxGlowRadius = maxRadius;
        this.startGlowRadius = startRadius;
        this.glowColor = color;
        this.glowSpeed = speed;
        if ((this.view instanceof TextView) || (this.view instanceof Button)) {
            if (this.startGlowRadius < this.minGlowRadius || this.startGlowRadius > this.maxGlowRadius) {
                this.startGlowRadius = (float) (new Random().nextInt((((int) this.maxGlowRadius) - ((int) this.minGlowRadius)) + 1) + ((int) this.minGlowRadius));
            }
            this.glowSpeed *= 25;
            startGlowing();
            return;
        }
        Toast.makeText(context, this.view.getClass().getName() + " view does not support Glowy Text Animation.", Toast.LENGTH_SHORT).show();
    }

    private void startGlowing() {
        this.handler = new Handler();
        this.f24r = new Runnable() {
            public void run() {
                if (GlowingText.this.view instanceof TextView) {
                    ((TextView) GlowingText.this.view).setShadowLayer(GlowingText.this.currentGlowRadius, GlowingText.this.f22dx, GlowingText.this.f23dy, GlowingText.this.glowColor);
                } else if (GlowingText.this.view instanceof Button) {
                    ((Button) GlowingText.this.view).setShadowLayer(GlowingText.this.currentGlowRadius, GlowingText.this.f22dx, GlowingText.this.f23dy, GlowingText.this.glowColor);
                }
                if (GlowingText.this.isDirectionUp) {
                    if (GlowingText.this.currentGlowRadius < GlowingText.this.maxGlowRadius) {
                        GlowingText.this.currentGlowRadius = 1.0f + GlowingText.this.currentGlowRadius;
                    } else {
                        GlowingText.this.isDirectionUp = false;
                    }
                } else if (GlowingText.this.currentGlowRadius > GlowingText.this.minGlowRadius) {
                    GlowingText.this.currentGlowRadius = GlowingText.this.currentGlowRadius - 1.0f;
                } else {
                    GlowingText.this.isDirectionUp = true;
                }
                GlowingText.this.handler.postDelayed(this, (long) GlowingText.this.glowSpeed);
            }
        };
        this.handler.postDelayed(this.f24r, (long) this.glowSpeed);
    }

    public void setStartGlowRadius(final float startRadius) {
        this.activity.runOnUiThread(new Runnable() {
            public void run() {
                GlowingText.this.startGlowRadius = startRadius;
            }
        });
    }

    public void setMaxGlowRadius(final float maxRadius) {
        this.activity.runOnUiThread(new Runnable() {
            public void run() {
                GlowingText.this.maxGlowRadius = maxRadius;
            }
        });
    }

    public void setMinGlowRadius(final float minRadius) {
        this.activity.runOnUiThread(new Runnable() {
            public void run() {
                GlowingText.this.minGlowRadius = minRadius;
            }
        });
    }

    public void setTransitionSpeed(final int speed) {
        this.activity.runOnUiThread(new Runnable() {
            public void run() {
                GlowingText.this.glowSpeed = speed;
            }
        });
    }

    public void setGlowColor(final int color) {
        this.activity.runOnUiThread(new Runnable() {
            public void run() {
                GlowingText.this.glowColor = color;
            }
        });
    }

    public float getStartGlowRadius() {
        return this.startGlowRadius;
    }

    public float getMaxGlowRadius() {
        return this.maxGlowRadius;
    }

    public float getMinGlowRadius() {
        return this.minGlowRadius;
    }

    public float getCurrentGlowRadius() {
        return this.currentGlowRadius;
    }

    public int getTransitionSpeed() {
        return this.glowSpeed;
    }

    public String getGlowColor() {
        return String.format("#%X", new Object[]{Integer.valueOf(this.glowColor)});
    }

    public void stopGlowing() {
        this.handler.removeCallbacks(this.f24r);
    }
}
